<script type="text/javascript" charset="utf-8"
	src="js/kind/kindeditor.js"></script>
<div class="event_pbox">
	<iframe id="uploadframe" name="uploadframe" width="0" height="0"
		marginwidth="0" frameborder="0" src="about:blank"
		style="display: none; z-index: 0;"></iframe>
	<form name="FORM" id="FORM" method="post"
		action="index.php?mod=journals&code=pevent"
		enctype="multipart/form-data" target="uploadframe">
		<table>
			<tr>
				<td>
					<table id="step1" align="left">
						<tr>
							<td width="100"><span>*</span>标题：</td>
							<td><input type="text" size="30" maxlength="50" id="name"
								name="name" value="{$title}" class="inputs"> <sup
								id="name_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span>*</span>出行方式：</td>
							<td>{$journals_type}</td>
						</tr>
						<tr>
							<td valign="top"><span>*</span>旅游地址：</td>
							<td>$province_list <input type="hidden" id="hid_province"
								name="hid_province" value="{$hid_province}"> <select
								id="city1" name="city" onchange="changeCity();">
									<option value='0'>请选择</option>
							</select> <input type="hidden" id="hid_city" name="hid_city"
								value="{$hid_city}"> <select id="area1" name="area"
								style="visibility: hidden">
									<option value='0'>请选择</option>
							</select> <input type="hidden" id="hid_area" name="hid_area"
								value="$hid_area"> <input type="text" id="address"
								name="address" value="{$address}" size="30" maxlength="50">
								<sup id="address_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<!--{if $top == 'top'}-->
						<tr>
							<td align="center">&nbsp;</td>
							<td><input type="button" id="next2" name="next2" value="下一步"
								onclick="set_step(2,this.form);return false;" class="btnText"></td>
						</tr>
						<!--{/if}-->
					</table>
				</td>
			</tr>
		</table>

		<table>
			<tr>
				<td>
					<table id="step2" align="left">
						<tr>
							<td><span>*</span>上传游记封面： <input type="file" id="pic"
								name="pic" onchange="onloadPic();"> <sup id="message"
								style="display: none; color: #FF0000;"></sup> <sup
								id='uploading' style="display: none"><img
									src="images/loading.gif">图片正在上传中、请稍等...</sup> <sup
								id="hid_pic_tips" style="display: none; color: #FF0000;"></sup>
								<input type="hidden" id="hid_pic" name="hid_pic"
								value="{$image}"></td>
						</tr>
						<tr id="img" style="display: none">
							<td><img id="showimg" name="showimg" src="{$image}"
								height="90" width="100"></img></td>
						</tr>
						<tr>
							<td><span>*</span>内容:<br> <textarea name="content1"
									id="content1" class="kindEditor" style="width: 625px; height: 500px;">{$content}</textarea>
								<sup id="content1_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<!--{if $top == 'top'}-->
						<tr>
							<td align="center"><input type="button" id="back1"
								name="back1" value="上一步"
								onclick="set_step(1,this.form);return false;" class="canlText"
								style="display: inline"> <input type="button" id="next3"
								name="next3" value="下一步"
								onclick="set_step(3,this.form);return false;" class="btnText"
								style="display: inline"></td>
						</tr>
						<!--{/if}-->
					</table>
				</td>
			</tr>
		</table>

		<table>
			<tr>
				<td>
					<table id="step3" align="left">
						<!--{if $info}-->
						<tr>
							<td>勾选报名时需要用户填写的内容：</td>
						</tr>
						<tr>
							<td>
								<!--{loop $info $key1 $val1}--> <label><input
									type="checkbox" id="{$val1['fieldid']}"
									name="info[{$val1['fieldid']}]" value={$key1}{$val1['checked']}>$val1['title']</label>
								<!--{/loop}-->
							</td>
						</tr>
						<!--{/if}-->
						<tr>
							<td align="center">
								<!--{if $top == 'top'}--> <input type="button" id="back2"
								name="back2" value="上一步"
								onclick="set_step(2,this.form);return false;" class="canlText">
								<!--{/if}--> <input type="button" name="SUBMIT" value="发布"
								onclick="formSubmit();" class="btnText" style="float:none;">&nbsp;&nbsp;
								<input type="button" value="保存为草稿箱"
								onclick="formSave();" class="btnText" style="float:none;"> <input
								type="hidden" id="top" name="top" value="{$top}"> <input
								type="hidden" id="act" name="act" value="{$act}"> <input
								type="hidden" id="id" name="id" value="{$id}">
								<input type="hidden" name="is_draft" value="0">
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	<div id="publish_share"></div>
	<script type="text/javascript">
function set_step(num,form){
	if(num == 1){
		$('#step1').show();
		$('#step2').hide();
		$('#step3').hide();
	}else if(num == 2){
		var check = checkEventStep1();
		if(check == false){return false;}
		$('#step1').hide();
		$('#step2').show();
		$('#step3').hide();
	}else if(num == 3){
		var check = checkEventStep2();
		if(check == false){return false;}
		
		$('#step1').hide();
		$('#step2').hide();
		$('#step3').show();
	}
}
<!--{if $top == 'top'}-->
$(document).ready(function() {
set_step(1);
})
<!--{/if}-->
function checkEventStep1(){
	var name = $("#name").val();
	if(strlen(name) < 2){
		$("#name_tips").html("标题必须有哦");
		$("#name_tips").show();
		$("#name").focus();
		return false;
	}else{$("#name_tips").hide();}

	//var address1 = $("#city").val();
	var address2 = $("#address").val();
	if(strlen(address2) < 2){
		$("#address_tips").html("游记地址必须有哦");
		$("#address_tips").show();
		$("#address").focus();
		return false;
	}else{$("#address_tips").hide();}
	
	return true;
}

function checkEventStep2(){
	var content = KindEditor.instances[0].html();
	$("#content1").val(content);
	if(strlen(content) < 2){
		$("#content1_tips").html("内容必须有哦");
		$("#content1_tips").show();
		$("#content1").focus();
		return false;
	}else{
		$("#content1_tips").hide();
	}
	return true;
}
function onloadPic(){
	var fn = $('#pic').val();
	if (!/.(gif|jpg|png|jpeg)$/i.test(fn)) {
		alert("请上传jpg、jpeg、gif、png格式的图片。");
		return false;
	}
	var top = $('#top').val();
	if(top == 'top'){
		document.getElementById('back1').style.display = 'none';
		document.getElementById('next3').style.display = 'none';
	}
	document.getElementById('uploading').style.display = 'block';
	document.FORM.target="uploadframe";
	document.FORM.action="ajax.php?mod=journals&code=onloadPic";
	$('#FORM').submit();
  }
function formSave(){
	document.FORM.target="";
	var top = document.getElementById('top').value;
	$("input[name='is_draft']").val('1');
	$("#content1").val(KindEditor.instances[0].html());
	var post_data = $('#FORM').serialize();
	$.post(
		"ajax.php?mod=journals&code=create&item="+__APPITEM__+"&item_id="+__APPITEM_ID__, 
		post_data, 
		function(r){
			if(is_json(r)){
				var json = eval('('+r.toString()+')');
				if (json.done) {
					if(top){
					    MessageBox('notice',json.msg);
						if($('#i_already').length > 0){
							$('#i_already').val(json.retval.content);
						}else{
							$('#i_alreadyajax').val(json.retval.content);
						}
						$(".menu_hdb").hide();
					}else{
						MessageBox('notice',json.msg);
						$("input[name='id']").val(json.retval.id);
						$("#act").val('edit');
					}
				} else {
					if(json.msg.indexOf('发布成功')>0){
						show_message_2(json.msg);
						if(!top){
							location.href = "index.php?mod=journals&code=myjournals";
						}else{
							$(".menu_hdb").hide();
						}
					}
					MessageBox('warning', json.msg);
				}
			}
		});
}
function formSubmit(){
	if(false === checkEventStep1()){
		return false;
	}
	if(false === checkEventStep2()){
		return false;
	}
	$("input[name='is_draft']").val('0');
	document.FORM.target="";
	var top = document.getElementById('top').value;
	var post_data = $('#FORM').serialize();
	$.post(
		"ajax.php?mod=journals&code=create&item="+__APPITEM__+"&item_id="+__APPITEM_ID__, 
		post_data, 
		function(r){
			if(!is_json(r)){
				var handle_key = 'publish_share';
				showDialog(handle_key, 'local', '分享', {html:r}, 500);
				
				$('#topic_simple_close_btn').click(
					function() {
						location.href = "index.php?mod=journals&code=detail&id="+$("#topic_simple_item_id").val();
					}
				);
				$('#topic_simple_share_btn').click(
					function () {
						var response = function() {
							location.href = "index.php?mod=journals&code=detail&id="+$("#topic_simple_item_id").val();
						}
						publishSimpleTopic($('#topic_simple_content').val(), 'journals', $("#topic_simple_item_id").val(), {response:response})
					}
				);
			}else{
				var json = eval('('+r.toString()+')');
				if (json.done) {
					if(top){
					    MessageBox('notice',json.msg);
						if($('#i_already').length > 0){
							$('#i_already').val(json.retval.content);
						}else{
							$('#i_alreadyajax').val(json.retval.content);
						}
						//$('#i_already').val(json.retval.content);
						//$('#mapp_item').val(json.retval.from);
						//$('#mapp_item_id').val(json.retval.id);
						$(".menu_hdb").hide();
					}else{
						MessageBox('notice',json.msg);
						location.href = "index.php?mod=journals&code=detail&id="+json.retval.id;
					}
				} else {
					if(json.msg.indexOf('发布成功')>0){
						show_message_2(json.msg);
						if(!top){
							location.href = "index.php?mod=journals&code=myjournals";
						}else{
							$(".menu_hdb").hide();
						}
					}
					MessageBox('warning', json.msg);
				}
			}
		}
	);
}

function changeProvince(){
  var province_id = document.getElementById("province").value;
  var hid_city = document.getElementById("hid_city").value;
  var url = "ajax.php?mod=member&code=sel&province="+province_id+"&hid_city="+hid_city;
  var myAjax=$.post(
		  	url,
		  	function(d){
	  		    $('#' + "city1").html(d);
		  		document.getElementById("area1").style.visibility = "hidden";
	  		    document.getElementById('area1').length = 1;
	  		    if(hid_city){
					changeCity();
	  		    }
		  	}
  );
}

$(document).ready(function() {
changeProvince();
})
function changeCity(){
  var city_id = document.getElementById("city1").value;
  var url = "ajax.php?mod=member&code=sel&city="+city_id+"&hid_area="+document.getElementById("hid_area").value;
  var myAjax=$.post(
		  	url,
		  	function(d){
				if(d){
					document.getElementById("area1").style.visibility = "visible";
		  		    $('#' + "area1").html(d);
				}else{
		  		    document.getElementById('area1').length = 1;
					document.getElementById("area1").style.visibility = "hidden";
				}
				document.getElementById("hid_province").value = '';
				document.getElementById("hid_city").value = '';
				document.getElementById("hid_area").value = '';
		  	}
);
}

function chooseuser(t){
  if(t == 'all'){
	document.getElementById("user").style.display = "none";
  }else if('qua'){
	document.getElementById("user").style.display = "block";
  }
}
<!--{if $qua}-->
$(document).ready(function() {
chooseuser('qua');
})
<!--{/if}-->
	
function choosemoney(t){
  if(t == 'money'){
	document.getElementById("money").readOnly = false;
  }else if(t == 'free'){
	document.getElementById("money").readOnly = "readonly";
  }
}
<!--{if $money}-->
$(document).ready(function() {
choosemoney('money');
})
<!--{/if}-->

function choosefans(){
  var fans = document.getElementById("fans").checked;
  if(fans){
    document.getElementById("fans_num").readOnly = false;
  }else{
	document.getElementById("fans_num").readOnly = "readonly";
  }
}
$(document).ready(function() {
choosefans();
})

<!--{if $image}-->
document.getElementById("img").style.display = 'block';
<!--{/if}-->
</script>
	<script src="js/date/WdatePicker.js" type="text/javascript"></script>
</div>